package com.lancoo.znbkxx.teacher.aibkTestCoach.studyAnalysis

import android.annotation.SuppressLint
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.PaperTypeName
import kotlinx.android.synthetic.main.item_study_analyisis_instruct.view.*
import java.math.BigDecimal

/**
 * Created by Dadong on 2021/2/22
 * Describe:
 */
class InstructAdapter(layoutResId: Int, instructData: MutableList<PaperTypeName>)
    : BaseQuickAdapter<PaperTypeName, BaseViewHolder>(layoutResId, instructData) {

    @SuppressLint("SetTextI18n")
    override fun convert(helper: BaseViewHolder, item: PaperTypeName?) {
        with(helper.itemView) {
            tv_score_rate.text = "平均得分率：${(item!!.ScoreRate * 100).toBigDecimal().setScale(0, BigDecimal.ROUND_HALF_UP)}%"
            when (helper.adapterPosition) {
                0 -> {
                    view_instruct.setPaintColor(helper.itemView.resources.getColor(R.color.cff7070))
                    tv_instruct.setTextColor(helper.itemView.resources.getColor(R.color.cff7070))
                    tv_instruct.text = "教材复习${item.Count}份" +
                            "（${(item.Rate * 100).toBigDecimal().setScale(0, BigDecimal.ROUND_HALF_UP)}%）"
                }
                1 -> {
                    view_instruct.setPaintColor(helper.itemView.resources.getColor(R.color.c2dbcff))
                    tv_instruct.setTextColor(helper.itemView.resources.getColor(R.color.c2dbcff))
                    tv_instruct.text = "专题复习${item.Count}份" +
                            "（${(item.Rate * 100).toBigDecimal().setScale(0, BigDecimal.ROUND_HALF_UP)}%）"
                }
                2 -> {
                    view_instruct.setPaintColor(helper.itemView.resources.getColor(R.color.cff9b00))
                    tv_instruct.setTextColor(helper.itemView.resources.getColor(R.color.cff9b00))
                    tv_instruct.text = "基础复习${item.Count}份" +
                            "（${(item.Rate * 100).toBigDecimal().setScale(0, BigDecimal.ROUND_HALF_UP)}%）"
                }
                3 -> {
                    view_instruct.setPaintColor(helper.itemView.resources.getColor(R.color.c22d7bb))
                    tv_instruct.setTextColor(helper.itemView.resources.getColor(R.color.c22d7bb))
                    tv_instruct.text = "拓展复习${item.Count}份" +
                            "（${(item.Rate * 100).toBigDecimal().setScale(0, BigDecimal.ROUND_HALF_UP)}%）"
                }
                4 -> {
                    view_instruct.setPaintColor(helper.itemView.resources.getColor(R.color.c3261fa))
                    tv_instruct.setTextColor(helper.itemView.resources.getColor(R.color.c3261fa))
                    tv_instruct.text = "校本试卷${item.Count}份" +
                            "（${(item.Rate * 100).toBigDecimal().setScale(0, BigDecimal.ROUND_HALF_UP)}%）"
                }
                5 -> {
                    view_instruct.setPaintColor(helper.itemView.resources.getColor(R.color.cb143ff))
                    tv_instruct.setTextColor(helper.itemView.resources.getColor(R.color.cb143ff))
                    tv_instruct.text = "模考复习${item.Count}份" +
                            "（${(item.Rate * 100).toBigDecimal().setScale(0, BigDecimal.ROUND_HALF_UP)}%）"
                }
            }
        }
    }
}